
Imports DAL

Public Class frmReport
    Public ReportName As String

    Private Sub btnOk_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnOk.Click
        'Dim Report As New Reports.frmReportViewer
        'Try
        '    If ValidateData() = False Then Exit Sub
        '    With Report
        '        Select Case ReportName
        '            Case "DateWiseSale"
        '                ReDim .ParametersNames(2)
        '                ReDim .ParametersValues(2)
        '                .ParametersNames(0) = "FromDate"
        '                .ParametersValues(0) = dtpFromDate.Value

        '                .ParametersNames(1) = "ToDate"
        '                .ParametersValues(1) = dtpToDate.Value

        '                .ParametersNames(2) = "ProfitInAorP"
        '                .ParametersValues(2) = "A"
        '                .Text = BCommon.GetReportHeading(ReportName)
        '                .ReportName = ReportName

        '                .ShowDialog()
        '            Case "PurchaseRegister", "SaleRegister"
        '                ReDim .ParametersNames(1)
        '                ReDim .ParametersValues(1)
        '                .ParametersNames(0) = "FromDate"
        '                .ParametersValues(0) = dtpFromDate.Value

        '                .ParametersNames(1) = "ToDate"
        '                .ParametersValues(1) = dtpToDate.Value
        '                .Text = BCommon.GetReportHeading(ReportName)
        '                .ReportName = ReportName
        '                .ShowDialog()

        '            Case "PendingPayments", "VendorWiseStock", "VendorPayment", "CompanyWiseStock", "ShelfWiseStock"
        '                ReDim .ParametersNames(0)
        '                ReDim .ParametersValues(0)
        '                If ReportName = "PendingPayments" Then
        '                    .ParametersNames(0) = "Vendor"
        '                ElseIf ReportName = "VendorWiseStock" Or ReportName = "VendorPayment" Then
        '                    .ParametersNames(0) = "VendorID"
        '                ElseIf ReportName = "CompanyWiseStock" Then
        '                    .ParametersNames(0) = "mfctrID"
        '                ElseIf ReportName = "ShelfWiseStock" Then
        '                    .ParametersNames(0) = "LocationID"
        '                End If

        '                If cmbPreferredV1.SelectedValue > 0 Then
        '                    .ParametersValues(0) = cmbPreferredV1.SelectedValue
        '                Else
        '                    .ParametersValues(0) = 0
        '                End If
        '                .Text = BCommon.GetReportHeading(ReportName)
        '                .ReportName = ReportName
        '                .ShowDialog()

        '                'Case "VendorWiseSale"
        '                '    ReDim .ParametersNames(2)
        '                '    ReDim .ParametersValues(2)

        '                '    .ParametersNames(0) = "FromDate"
        '                '    .ParametersValues(0) = dtpFromDate.Value

        '                '    .ParametersNames(1) = "ToDate"
        '                '    .ParametersValues(1) = dtpToDate.Value

        '                '    .ParametersNames(2) = "Profit In A/P"
        '                '    .ParametersValues(2) = "A"
        '                '    .Text = "Vendorwise Sale Report"
        '                '    'Case "VendorPayment"

        '                '    '    'ReDim .ParametersNames(0)
        '                '    '    'ReDim .ParametersValues(0)

        '                '    '    '.ParametersNames(0) = "Vendor"
        '                '    '    '.ParametersValues(0) = cmbVendorList.Columns(0).Value
        '                '    '    .Text = "Vendorwise Pending Payment Report"
        '                'Case "ItemWiseSale"

        '                '    ReDim .ParametersNames(2)
        '                '    ReDim .ParametersValues(2)

        '                '    .ParametersNames(0) = "FromDate"
        '                '    .ParametersValues(0) = Format(dtpFromDate.Value, "dd/MM/yy")

        '                '    .ParametersNames(1) = "ToDate"
        '                '    .ParametersValues(1) = Format(dtpToDate.Value, "dd/MM/yy")

        '                '    '.ParametersNames(2) = "ItemID"
        '                '    '.ParametersValues(2) = 1

        '                '    .ParametersNames(2) = "Profit In A/P"
        '                '    .ParametersValues(2) = "A"
        '                '    .Text = "Itemwise Sale Report"
        '                'Case "DateWiseSale"

        '                '    ReDim .ParametersNames(2)
        '                '    ReDim .ParametersValues(2)

        '                '    .ParametersNames(0) = "FromDate"
        '                '    .ParametersValues(0) = Format(dtpFromDate.Value, "dd/MM/yy")

        '                '    .ParametersNames(1) = "ToDate"
        '                '    .ParametersValues(1) = Format(dtpToDate.Value, "dd/MM/yy")

        '                '    '.ParametersNames(2) = "ItemID"
        '                '    '.ParametersValues(2) = 1

        '                '    .ParametersNames(2) = "Profit In A/P"
        '                '    .ParametersValues(2) = "A"
        '                '    .Text = "Datewise Sale Report"

        '                'Case "SaleBill"
        '                '    'ReDim ParametersNames(1)
        '                '    'ReDim ParametersValues(1)

        '                '    'ParametersNames(1) = "PersonName"
        '                '    'ParametersValues(1) = "Dr.Rakesh Deore"

        '                '    'ParametersNames(0) = "SaleID"
        '                '    'ParametersValues(0) = 1
        '                'Case "PurchaseInvoices"
        '                '    'ReDim .ParametersNames(0)
        '                '    'ReDim .ParametersValues(0)

        '                '    '.ParametersNames(0) = "InvoiceID"
        '                '    '.ParametersValues(0) = 1
        '                '    '.Text = "Purchase Invoice Report"
        '                'Case "ExpiredStock"
        '                'Case "ItemsNearToExpiry"
        '                'Case "VendorPayment"
        '                'Case "OutStandingPayments"
        '        End Select
        '    End With
        '    Me.Close()
        'Catch ex As Exception
        '    BCommon.ErrorHandler(ex.Message, Me.ProductName, Me.Name, "btnOk_Click")
        'End Try
    End Sub

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnCancel.Click
        Me.Close()
    End Sub

    Private Sub frmReport_HelpButtonClicked(ByVal sender As Object, ByVal e As System.ComponentModel.CancelEventArgs) Handles Me.HelpButtonClicked
        'Rauhl_ITS@20073012 : Add following code display help
        Help.ShowHelp(Me, "Pharma.chm", HelpNavigator.KeywordIndex, "Report Preview")
        e.Cancel = True
    End Sub

    Private Sub frmReport_KeyUp(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles Me.KeyUp
        If e.KeyCode = Keys.F1 Then
            'Rauhl_ITS@20073012 : Add following code display help
            e.SuppressKeyPress = True
            Help.ShowHelp(Me, "Pharma.chm", HelpNavigator.KeywordIndex, "Report Preview")
        End If
    End Sub

    Private Sub frmReport_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        Call DisplayData()
    End Sub

    Private Function ValidateData() As Boolean
        If dtpFromDate.Text > dtpToDate.Text Then
            BCommon.ShowMsgError(10244)
            Return False
        End If
        Return True
    End Function

    Private Sub btnOk_MouseLeave(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnOk.MouseLeave
        btnOk.BackColor = Color.AliceBlue
        btnOk.ForeColor = Color.Black
    End Sub

    Private Sub btnOk_MouseMove(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles btnOk.MouseMove
        btnOk.BackColor = Color.LightSeaGreen
        btnOk.ForeColor = Color.White
    End Sub

    Private Sub btnCancel_MouseLeave(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnCancel.MouseLeave
        btnCancel.BackColor = Color.AliceBlue
        btnCancel.ForeColor = Color.Black
    End Sub

    Private Sub btnCancel_MouseMove(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles btnCancel.MouseMove
        btnCancel.BackColor = Color.LightSeaGreen
        btnCancel.ForeColor = Color.White
    End Sub
    'Divya 22/11/2007
    Private Sub SetDatepickerMaxMinDate()
        Dim dtDatePkr As DataTable
        Try
            dtDatePkr = BCommon.GetDatePicker()
            dtpFromDate.MinDate = dtDatePkr.Rows(0).Item("fin_start_dt")
            dtpFromDate.MaxDate = dtDatePkr.Rows(0).Item("fin_end_dt")
            dtpToDate.MinDate = dtDatePkr.Rows(0).Item("fin_start_dt")
            dtpToDate.MaxDate = dtDatePkr.Rows(0).Item("fin_end_dt")
        Catch ex As Exception
            BCommon.ErrorHandler(ex.Message, Me.ProductName, Me.Name, "SetDatepickerMaxMinDate")
        End Try
    End Sub
    Private Sub DisplayData()
        Try
            Call SetDatepickerMaxMinDate()
            Me.Text = BCommon.GetReportHeading(ReportName)
            Call BCommon.SetFormStandards(Me)

            'Call BCommon.AssignLabels(Me.ProductName, Me) 'Vrushali    27/07/2007
            Select Case ReportName
                Case "DateWiseSale", "PurchaseRegister", "SaleRegister"
                    grpdate.Visible = True
                    grpbVendor.Visible = False
                Case "PendingPayments", "VendorWiseStock", "VendorPayment", "CompanyWiseStock", "ShelfWiseStock"
                    grpbVendor.BringToFront()
                    grpbVendor.Visible = True
                    grpdate.Visible = True
                    If ReportName = "CompanyWiseStock" Then
                        lblVendor.Text = "&Manufacturer"
                        BCommon.SetComboValues(cmbPreferredV1, BManufacturer.GetManufacturers(), "mfctrID", "mfctrName")
                    ElseIf ReportName = "ShelfWiseStock" Then
                        lblVendor.Text = "&Location"
                        BCommon.SetComboValues(cmbPreferredV1, BLocation.GetLocation(), "LocationID", "LocationCode")
                    Else
                        lblVendor.Text = "&Vendor"
                        BCommon.SetComboValues(cmbPreferredV1, BVendor.GetVendor(), "VendorID", "VendorName")
                    End If
                    'cmbPreferredV1.SelectedIndex = 1
            End Select
            '1:      "VendorWiseStock"
            '2:      "CompanyWiseStock"
            '3:      "ShelfWiseStock"
            '4:      "ItemsNearToExpiry"
            '5:      "ExpiredStock"
            '6:      "PurchaseInvoices"
            '7:      "DelliveryChallan"     'Incomplete
            '8:      "DelliveryChallanToPI" 'Incomplete 
            '9:      "SaleBill"
            '10:     "CounterSale"
            '11:     "VendorWiseSale"
            '12:     "ItemWiseSale"
            '13:     "DateWiseSale"
            '14:     "PurchaseReturn"
            '15:     "SaleReturn"
            '16:     "PaymentReceipt"
            '17:     "VendorPayment"
            '18:     "PendingPayments"
            '19:     "OutStandingPayments"
        Catch ex As Exception
            BCommon.ErrorHandler(ex.Message, "Pharmacy", Me.Name, "displayData")
        End Try
    End Sub
    
End Class